package com.hxzy.sendMail;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts2.ServletActionContext;

import com.opensymphony.xwork2.ActionSupport;

public class IndexAction extends ActionSupport {

	/**
	 * 
	 */
	private static final long serialVersionUID = 426761381571314793L;
	
	private String recieve;
	private String qq;
	private String passwd;
	private String title;
	private String content;
	
	
	
	public String execute() throws Exception {
		// TODO Auto-generated method stub
		if("POST".equals(ServletActionContext.getRequest().getMethod())){
			 MailSenderInfo mailInfo = new MailSenderInfo();
		        mailInfo.setMailServerHost("smtp.qq.com");
		        mailInfo.setMailServerPort("587");
		        mailInfo.setValidate(true);
		        mailInfo.setFromAddress(qq+"@qq.com");
		        mailInfo.setToAddress(recieve);
		        mailInfo.setUserName(qq+"@qq.com");
		        mailInfo.setPassword(passwd);
		        mailInfo.setSubject(title);
		        mailInfo.setContent(content);
		        boolean isSend =    SimpleMailSender.sendTextMail(mailInfo);
		        if(isSend){
		        return SUCCESS;
		        }
		        addFieldError("title", "失败");
		        return INPUT;
		}
		 return INPUT;
	}



	public String getRecieve() {
		return recieve;
	}



	public void setRecieve(String recieve) {
		this.recieve = recieve;
	}



	public String getQq() {
		return qq;
	}



	public void setQq(String qq) {
		this.qq = qq;
	}



	public String getPasswd() {
		return passwd;
	}



	public void setPasswd(String passwd) {
		this.passwd = passwd;
	}



	public String getTitle() {
		return title;
	}



	public void setTitle(String title) {
		this.title = title;
	}



	public String getContent() {
		return content;
	}



	public void setContent(String content) {
		this.content = content;
	}
	
	
	
	
}
